import PyMap from "./PyMap.vue";
const BAIDU_MAP_ID = "BAIDU_MAP_ID";
function loadBMap(ak: string) {
	return new Promise(function (resolve, reject) {
		if (typeof (window as any).BMap !== "undefined") {
			resolve((window as any).BMap);
			return true;
		}
		(window as any).onBMapCallback = function () {
			resolve((window as any).BMap);
		};
		if (document.getElementById(BAIDU_MAP_ID)) return;
		let script = document.createElement("script");
		script.id = BAIDU_MAP_ID;
		script.type = "text/javascript";
		script.src = "http://api.map.baidu.com/api?v=2.0&ak=" + ak + "&callback=onBMapCallback";
		script.onerror = reject;
		document.head.appendChild(script);
	});
}

export { PyMap, loadBMap };
export * from "./type";
